import React from 'react';
import { View, Text } from '@tarojs/components'
import './index.scss';

const Modal = ({ isOpen, onClose, children, position }) => {
  if (!isOpen) return null;
  let alignItems = position === 'bottom' ? 'flex-end' : 'center'
  return (
    <View className="modal-backdrop" style={{ alignItems }} onClick={onClose}>
      <View className="modal-content" onClick={e => e.stopPropagation()}>
        {children}
      </View>
    </View>
  );
};
export default Modal;